﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FrmMessageEdit.aspx.cs" Inherits="Web.AdminPage.FrmMessageEdit" %>

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="../css/bootstrap.min.css" rel="stylesheet" />
    <link href="../css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="../css/animate.min.css" rel="stylesheet">
    <link href="../css/style.min.css?v=4.1.0" rel="stylesheet">
      <link href="../css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="../css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
    <title>Edit</title>
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content">
        <div  id="frm">
            <div class="row">
                <div class="col-sm-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>编辑</h5>
                            <input type="hidden" id="Id" name="Id" value="<%=model.Id %>"
                                class="form-control" />
                            <div class="ibox-tools">
                                <button id="edit" class="btn btn-primary btn-xs m-l-sm" onclick="edit()" type="button">编辑</button>
                                <button id="save" class="btn btn-primary  btn-xs" type="button" onclick="save()">保存</button>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">类型</label>
                            <div class="col-sm-10">
                                <input type="text" id="mes_type_id" name="mes_type_id" readonly value="<%=model.mes_type_id %>" placeholder="类型" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">标题</label>
                            <div class="col-sm-10">
                                <input type="text" id="title" name="title" value="<%=model.title %>" placeholder="标题" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">内容</label>
                            <div class="col-sm-10">
                                <div class="ibox-content" id="eg">

                                    <div class="click2edit wrapper">
                                       <%=model.contents %>
                                    </div>

                                </div>
                              
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">时间</label>
                            <div class="col-sm-10">
                                <input type="text" id="create_time" name="create_time" value="<%=model.create_time %>" placeholder="时间" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">创建人</label>
                            <div class="col-sm-10">
                                <input type="text" id="server_id" name="server_id" readonly value="<%=model.server_id %>" placeholder="创建人" class="form-control" />
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="../js/jquery.min.js?v=2.1.4"></script>
    <script src="../js/bootstrap.min.js?v=3.3.6"></script>
    <script src="../js/content.min.js?v=1.0.0"></script>
   <%-- <script src="../js/jquery.form.js"></script>--%>
     <script src="../js/plugins/summernote/summernote.min.js"></script>
    <script src="../js/plugins/summernote/summernote-zh-CN.js"></script>
    <script>
       
        $(document).ready(function () {
            $(".summernote").summernote({ lang: "zh-CN" });
            
        });
        var edit = function () {
            $("#eg").addClass("no-padding");
            $(".click2edit").summernote({ lang: "zh-CN", focus: true })
        };

        var save = function () {
            $("#eg").removeClass("no-padding");
            var aHTML = $(".click2edit").code();
            $(".click2edit").destroy();
            $.ajax({
                type: "POST",
                url: "../Hanlder/MessageHandler.ashx?Method=Edit",
                data: { Id: "<%=model.Id%>", title: $("#title").val(), contents: aHTML, create_time: $("#create_time").val(), server_id: "<%=model.server_id%>", mes_type_id: "<%=model.mes_type_id%>" },
                    dataType: "json",
                    success: function (res) {
                        if (res.states == 0) {
                            var index = parent.layer.alert('操作成功', function () {



                            })
                        } else {
                            parent.layer.msg(res.msg);
                        }
                    }
                });
            };
    
    </script>
    
</body>
</html>
